package com.cloud.applet.util;

/**
 * @Description:
 * @ClassName: MathUtils
 * @Date: 2024/7/22 11:28
 * @Version: 1.0     // 版本
 */
public class MathUtils {

    public static int calculatePercentage(int part, int whole) {
        if (whole == 0) {
            throw new IllegalArgumentException("The whole value cannot be zero.");
        }

        double percentage = ((double) part / whole) * 100;
        int roundedPercentage = (int) Math.round(percentage);

        return roundedPercentage;
    }
}
